package czh.cocoa.foundation;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class NSSet extends NSObject implements Iterable<NSObject> {

	Set<NSObject> mSet;
	
	public static NSSet setWithObjects(NSObject... objects) {
		NSSet set = new NSSet();
		for (NSObject o : objects) {
			set.mSet.add(o);
		}
		return set;
	}
	
	public NSSet() {
		mSet = new HashSet<NSObject>();
	}
	
	public NSSet(NSArray array) {
		this();
		for (NSObject o : array) {
			mSet.add(o);
		}
	}
	
	public NSObject anyObject() {
		for (NSObject o : mSet) {
			return o;
		}
		return null;
	}
	
	public NSArray allObjects() {
		NSArray array = new NSArray(count());
		for (NSObject o : mSet) {
			array.mArray.add(o);
		}
		return array;
	}
	
	public boolean containsObject(NSObject o) {
		return mSet.contains(o);
	}
	
	public int count() {
		return mSet.size();
	}
	
	@Override
	public Iterator<NSObject> iterator() {
		return mSet.iterator();
	}
 	
}




